<?php

require_once 'common/conn.php';
if (isset($_GET['start'])) {
    $num = $_GET['start'];
} else {
    $num = 0;
}
if (isset($_GET['limit'])) {
    $count = $_GET['limit'];
}

if (isset($_GET['difficult'])) {
    $difficult = $_GET['difficult'];
}

$data = array();
if (is_numeric($num) && is_numeric($count)) {
    $db = new DBC();
    $sql = "SELECT code FROM t_game_answer WHERE type = 'voice' AND difficult = '" . $difficult . "' LIMIT " . $num . "," . $count;
    $temp = $db->fetchData($sql);
    if ($temp != false && count($temp) > 0) {
        for ($i = 0; $i < count($temp); $i++) {
            $obj = array();
            $obj['code'] = $temp[$i]['code'];
            $obj['version'] = $temp[$i]['version'];
            $obj['url'] = $temp[$i]['url'];
            $obj['type'] = $temp[$i]['type'];
            $obj['name'] = $temp[$i]['code'];
            array_push($data, $obj);
        }
    }
}
echo json_encode($data);
?>